home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1995 October
/
EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso
/
Aminet
/
comm
/
fido
/
FQUERY.lha
/
rexx
/
FQscan.rexx
Wrap
OS/2 REXX Batch file
|
1995-04-11
|
9KB
|
295 lines
/**/
v="$VER: FQscan Rexx Packet Scanner for FQUERY Williamson 55.67"
if ~show('L',"rexxsupport.library") then
if ~addlib("rexxsupport.library",0,-30,0) then do
say "Couldn't access support.library !"
EXIT 20
end
if arg()=0 then do
say;Say subword(v,4);say
say ' usage: FQscan [cfgfile] list of packets'
say ' eg: FQscan cfg:FQ.cfg mail:audit/35656187.pkt mail:inbound/12567736.pkt'
say ' The cfgfile can be omitted if it is in the assigned volume CFG:'
say ' eg: FQscan mail:audit/35656187.pkt mail:inbound/12567736.pkt'
say ' or'
say ' FQscan SHOW'
say ' Displays configuration'
say
exit
end
log=show('p','ROOFLOG')
PROGLIST="FILEFIND ALLFIX FQUERY FILEQUERY"
parse arg args
if pos("FQ.CFG",upper(ARGS))>0 then do
parse var args cfg files
cfg=strip(cfg)
end;else do
files=args
cfg="CFG:FQ.CFG"
end
files=strip(files)
if ~open('cfg',cfg,'r') then do
Say 'Cannot find 'cfg
exit 10
end
SOH=d2c(1);CR='0D'x;LF='0A'x
TRUE=1;FALSE=0
maxbuf=(1024*32);lbuf=""
fqm=0;fqt=0;findlist=""
do while ~eof('cfg')
q=upper(readln('cfg'))
if q="" | left(q,1)=" " then iterate
parse var q vname vval
vname=upper(vname)
select
when vname="NONETSCAN" then nonetscan=strip(vval)==TRUE
when vname="SITELIST" then sitelist=dequote(vval)
when vname="MSGLIST" then msglist=dequote(vval)
when vname="FTNLIST" then ftnlist=dequote(vval)
when vname="FQLOG" then FQLOG=dequote(vval)
when vname="LOGLEVEL" then LOGLEVEL=strip(vval)
when left(vname,7)="FQECHO." then FINDLIST=FINDLIST||upper(strip(dequote(vval)))" "
otherwise nop
end
end
call close('cfg')
if ~NONETSCAN then FINDLIST="NETMAIL "||strip(FINDLIST)
if pos("SHOW",upper(args))>0 then do
bol.0="FALSE";bol.1="TRUE"
say;Say subword(v,4);say
say " NoNetScan :"bol.NONETSCAN
say " SiteList :"SITELIST
say " FindList :"FINDLIST
say " MsgList :"MSGLIST
say " FQlog :"FQLOG
say " LogLevel :"LOGLEVEL
say " FTNlist :"FTNLIST
exit
end
do while words(files)>0
parse var files packet " " files
if ~open('pkt',packet,'R') then do
call writelog("Cannot open "packet,0)
iterate
end;else do
fqm=0
pktlen=subword(statef(packet),2,1)
call writelog("Packet:" packet "Size:"pktlen,4)
if pktlen<(1024*63) then do
pbufed=0
pbuf=readch('pkt',pktlen)
call close('pkt')
buflen=pktlen
validsite=scanhdr()
if ~validsite then Iterate
offset=58
end;else do
pbufed=1
pbuf=readch('pkt',58)
validsite=scanhdr()
if ~validsite then do
call close('pkt')
Iterate
end
call loadbuf()
end
msgs=0
do forever
if offset>=buflen then do
if ~loadbuf() then leave
end
z=getint(offset)
if z~=2 then do
call writelog(c2x(z) 'Not 0200 at offset:'offset,9)
if offset=buflen then leave
offset=offset+2
call writelog('Bumped offset:'offset,9)
end
tagname="NETMAIL";intl="";msgid="";fmpt="";morg="";msgs=msgs+1
call writech(STDOUT,CR'Msg:'msgs' ')
pfrom=getint(offset+6)"/"getint(offset+2)
pto=getint(offset+8)"/"getint(offset+4)
flags=getword(offset+10)
cost=getint(offset+12)
offset=offset+14 /* 34 */
msgdate=getstring()
toname=upper(getstring())
fromname=getstring()
subject=getstring()
text=getstring()
if text="" then leave
if left(text,5)="AREA:" then tagname=substr(text,6,pos('0D'x,text,6)-6)
if pos(word(toname,1)||" ",proglist)>0 & pos(tagname,findlist)>0 then do
z=pos(SOH"INTL",text)
if z>0 then do
mpos=z+5
intl=word(strip(strip(substr(text,mpos,pos('0D'x,text,mpos+1)-mpos)),'L',':'),1)
end
z=pos(SOH"MSGID: ",text)
if z>0 then do
mpos=z+8
Msgid=substr(text,mpos,pos('0D'x,text,mpos+1)-mpos)
end
z=pos(SOH"FMPT",text)
if z>0 then do
mpos=z+5
fmpt=strip(strip(substr(text,mpos,pos('0D'x,text,mpos+1)-mpos)),'L',':')
end
z=pos(" * Origin: ",text)
if z>0 then do
moxxy=substr(text,z,pos('0D'x,text,z+1)-z)
ox=lastpos(')',MOXXY)
oy=lastpos('(',MOXXY,ox-1)
morg=substr(MOXXY,oy+1,(ox-1)-oy)
end
if loglevel>8 then do
call writelog("Area: " tagname)
call writelog("From: " fromname)
call writelog("To: " toname)
call writelog("Subj: " subject)
call writelog("Date: " msgdate)
call writelog("Origin: " morg)
call writelog("Intl: " intl)
call writelog("Msgid: " msgid)
call writelog("Fmpt: " fmpt)
say
end
if morg="" & intl~="" then morg=intl
if tagnme="NETMAIL" & NONETSCAN then iterate
lbuf=lbuf||tagname'|'toname'|'fromname'|'subject'|'msgdate'|'morg'|'msgid'|'fmpt||LF
fqm=fqm+1
end
end
end
if pbufed then call close('pkt')
call writelog('Found 'fqm' queries in 'packet' from 'fromsite,1)
fqt=fqt+fqm
end
if lbuf~="" then do
if ~open('l',msglist,'a') then do
if ~open('l',msglist,'w') then do
call writelog('Cannot open 'msglist,0)
exit 20
end
end
call writech('l',lbuf)
call close('l')
end
if words(files)>0 then call writelog('Found 'fqt' total queries',1)
exit
scanhdr:
if getint(18) ~=2 then do
call writelog("Packet type" getint(18)", can't process this type",0)
return 0
end;else do
product=getbyte(24)
ozone=getint(46);if ozone=0 | ozone=256 then ozone=getint(34)
dzone=Getint(48);if dzone=0 | dzone=256 then dzone=getint(36)
if ozone=0 | ozone=256 | dzone=0 | dzone=256 then do
call writelog("ERR: Can't find ftn, zone undefined",0)
return 0
end
oftn=find_ftn(ozone)
dftn=find_ftn(dzone)
fromsite=oftn"#"ozone":"getint(20)"/"getint(0)"."getint(50)
call writelog("From:" fromsite,3)
call writelog("To:" dftn"#"dzone":"getint(22)"/"getint(2)"."getint(52),3)
call writelog("Date:"getint2(8)"."getint2(6)"."getint(4)" "getint2(10)":"getint2(12)":"getint2(14),3)
z=getint(16)
if pos(upper(fromsite),sitelist)=0 then do
call writelog(packet' from 'fromsite', not valid feed',0)
return 0
end
end
return 1
getword: return reverse(substr(pbuf,arg(1)+1,2))
getint: return c2d('00'x||reverse(substr(pbuf,arg(1)+1,2)))
getint2: return right('00'||c2d('00'x||reverse(substr(pbuf,arg(1)+1,2))),2)
getbyte: return c2d('00'x||substr(pbuf,arg(1)+1,1))
getstring:
if offset>buflen then return ""
actpos=offset+1
offset=Pos('00'x,pbuf,actpos)
if offset=0 then do
call writelog('Error: cannot find NULL @ offset'actpos offset '=' c2x(substr(pbuf,actpos-1)),1)
offset=buflen
end
return substr(pbuf,actpos,offset-actpos)
loadbuf:
call writelog("LoadBuf FilePos:"seek('pkt',0,'C'),9)
pbuf=readch('pkt',maxbuf)
buflen=length(pbuf)
if buflen=0 then return 0
call writelog('This pbuf Start:'c2x(left(pbuf,16)),9)
call writelog('This pbuf End:' c2x(right(pbuf,16)),9)
if c2x(right(pbuf,3))='000000' then do
call writelog('07'x 'Last pbuf Length:'buflen,9)
offset=0
return 1
end
if loglevel>8 then do
call writelog('This pbuf Length:' buflen,9)
call writelog("LoadBuf FilePos:"seek('pkt',0,'C'),9)
end
LastMsgPos=lastpos('000200'x,pbuf)
LastMsgStart=LastMsgPos+1
if loglevel>8 then do
call writelog('Next:'c2x(substr(pbuf,LastMsgStart,16)))
call writelog('Read:'buflen' LastMsg:'LastMsgStart '+58(header)='LastMsgStart+58)
call writelog('Size:'buflen-(buflen-(LastMsgStart)))
end
seek_off=(LastMsgStart-buflen)-1
newpos=seek('pkt',seek_off,'C')
pbuf=delstr(pbuf,LastMsgStart)
buflen=length(pbuf)
if loglevel>8 then do
call writelog('Seek Offset:'seek_off' Respositioned:'newpos)
call writelog('New End:' c2x(right(pbuf,16)))
call writelog('New Length:'buflen)
end
offset=0
return 1
find_ftn: procedure expose ftnlist
if pos(arg(1),"1 2 3 4 5 6")>0 then return "FIDONET"
if pos(arg(1),"39 40 41")>0 then return "AMIGANET"
dz=FIND(ftnlist,arg(1))
if dz=0 then return 0
else return strip(word(ftnlist,dz-1))
/* a useful procedure by Walt Sullivan */
dequote:
parse arg thing
parse var thing '"' unq_thing '"'
if unq_thing~="" then return unq_thing
return thing
WriteLog: procedure expose log FQlog loglevel
if arg(2)>loglevel then return 0
call writeln(STDOUT,arg(1))
if ~open('tl',FQLOG,'A') then do
if ~open('tl',FQLOG,'W') then do
Say 'Cannot open 'FQLOG
return 0
end
end
call writeln('tl',time() arg(1));call close('tl')
if log then address "ROOFLOG" 'LOGLINE 'left(time(),5) 'FQuery: 'arg(1)
return 0